home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / csg / README < prev   
Encoding:
Text File  |  1994-08-02  |  1.9 KB  |  44 lines

  1.  
  2.               ~4Dgifts/toolbox/src/exampleCode/csg README
  3.  
  4.  
  5.     csg demos implementation of boolean operations with stencil planes.
  6.  
  7.  
  8.     the file csg-paper is the copy of a paper by Kurt Akeley titled, 
  9.     "Constructive Solid Geometry, Stencil planes and solid geometry 
  10.     applications"
  11.  
  12.  
  13.     csg.c draws a CSG object - a cube with a hole drilled through the
  14.     center.  The stencil planes are used to determine where the cube
  15.     should be drawn and where the cylinder should be drawn.
  16.  
  17.     There are several things to bear in mind.  The cube is drawn
  18.     "normally"; that is, with its back faces removed.  The cylinder is
  19.     subtracted from the cube, so only its BACK faces will show.  Also,
  20.     the cube is NOT drawn wherever it is inside the cylinder.  The stencil
  21.     planes and the z-buffer are used together to figure out where the
  22.     cube is inside the cylinder.
  23.   
  24.     The drawscene() routine does the CSG.  The basic algorithm is as
  25.     follows:
  26.                1  Turn off drawing.
  27.                2  Render the cube's z-values into the z-buffer planes.
  28.                3  Use the stencil and the z-buffer comparison hardware
  29.                     to count how many times the cylinder is drawn in
  30.                     front of the cube.
  31.                4  Wherever exactly one face of the cylinder is in front
  32.                     of the cube (in other words, the cube is between
  33.                     or inside the cylinder), force z-values to the
  34.                     largest possible z, because these pixels are inside
  35.                     the hole in the cube.
  36.                5  Render the cube's back faces into this hole as needed (to
  37.                     clip the back of the cylinder).
  38.                6  Render the cylinder's z-values into this hole as needed.
  39.                7  Turn drawing on.
  40.                8  Render the cube and cylinder where their z-values equal
  41.                     the values in the z-buffer planes.
  42.  
  43.  
  44.